﻿@{
    Layout = "../Shared/_InnerPage.cshtml";
}
@model XoohooViewModelItem<IEnumerable<UserGroup>>
@section TitleContent{
    @Html.SiteTitle("系统管理", "用户管理", "用户组管理", "用户组列表")
}
@section HeadCustom{
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $(".delete>a").click(function () {
                if (!confirm("警告！删除该用户组后，该用户组下的用户将自动移入\"等待分配组！\n确定要删除该用户组？")) { return false; }
            });
        });
    </script>
}
@section NavigationContent
{
    当前位置：用户管理 &gt;&gt; 用户组管理 &gt;&gt; 用户组列表
}
@{
    IEnumerable<UserGroup> userGroups = Model.Item;
    Html.BeginRouteForm("Admin.Membership.User.UserGroupList", FormMethod.Post, new { @id = "UserGroupSearchForm", @name = "UserGroupSearchForm" });
    if (!userGroups.IsNullOrEmpty())
    {
        int maxDisplayOrder = userGroups.Max(v => v.DisplayOrder);
        WriteLiteral(Html.Grid(userGroups).Columns(column =>
        {
            column.For(item => item.DisplayOrder).Named("顺序").HeaderAttributes(@class => "titNum").Attributes(@class => "conNum");
            column.For(item => item.UserGroupName).Encode(false).Named("用户组名称").HeaderAttributes(@class => "titOth").Attributes(@class => "conOth");
            column.For(item => Html.ActionLink("添加子组", "UserGroupAdd", new { ParentID = item.UserGroupID })).Encode(false).Attributes(@class => "conCtr2").CellCondition(p => !p.IsSystem);
            column.For(item => Html.ActionLink("上移", "UserGroupMove", new { UserGroupID = item.UserGroupID, Target = MovingTarget.Up })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => p.DisplayOrder > 3);
            column.For(item => Html.ActionLink("下移", "UserGroupMove", new { UserGroupID = item.UserGroupID, Target = MovingTarget.Down })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => p.DisplayOrder != maxDisplayOrder && p.DisplayOrder > 2);
#if DEBUG
    column.For(item => Html.ActionLink("编辑", "UserGroupEdit", new { UserGroupID = item.UserGroupID })).Encode(false).Attributes(@class => "conCtr");
#else
            column.For(item => Html.ActionLink("编辑", "UserGroupEdit", new { UserGroupID = item.UserGroupID })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => !p.IsSystem);
#endif
            column.For(item => Html.ActionLink("删除", "UserGroupRemove", new { UserGroupID = item.UserGroupID })).Encode(false).Attributes(@class => "conCtr delete").CellCondition(p => !p.IsSystem);
            column.For(item => item.IsSystem ? "系统" : String.Empty).Encode(false).Attributes(@class => "conCtr");
        })
            //表格属性
.Attributes(@class => "tbl")
            //表头行属性
.HeaderRowAttributes(new Hash(@class => "rowhead"))
            //列表行属性
.RowAttributes(data => new Hash(@class => "{0}".FormatWith(data.IsAlternate ? "rowodd" : ""))));
    }
}
@{Html.EndForm();}
